const url = {
    personLogin: "/api/v1/admin/personLogin",//人事管理登錄
    salaryLogin: "/api/v1/admin/salaryLogin",//薪酬管理登錄
    addEmployee: "/api/v1/admin/addEmployee",//档案登记
    selectEmployee: "/api/v1/admin/selectEmployee",//档案查询
    switchSelEmployee: "/api/v1/admin/switchSelEmployee",//条件档案查询
    updateEmployee: "/api/v1/admin/updateEmployee",//档案修改
    deleteEmployee: "/api/v1/admin/deleteEmployee",//档案删除
    checkEmployee: "/api/v1/admin/checkEmployee",//档案复核
    selectOrg: "/api/v1/admin/selectOrg",//获取所有机构名
    selectPosition: "/api/v1/admin/selectPosition",//获取所有职称名
    addSalary: '/api/v1/admin/addSalary',//薪酬登记
    selectSalary: "/api/v1/admin/selectSalary",//查看薪酬
    selectSalaryID: "/api/v1/admin/selectSalaryID",//按照id查看薪酬
    checkSalary: "/api/v1/admin/checkSalary",//薪酬复核
    deleteSalary: '/api/v1/admin/deleteSalary'//删除薪酬标准

}
// console.log("hello")
// 创建网络请求模块
angular.module("NetworkRequest", [])
//     .config(function ($httpProvider) {
//         // $httpProvider.defaults.withCredentials = true;//允许发送cookie
//         // $httpProvider.defaults.headers.common['Authorization'] = document.cookie.split(";")[0].split("user_token=")[1];
//     })
    .controller("NetworkRequestCtro", ['$scope', '$http', function ($scope, $http) {

        //注意$http get 拼接参数用params   post用data
        //发送GET请求
        $scope.GET = function (url, paramter, success, error) {
        console.log(url,paramter )
            $http({
                method: 'GET',
                url:  url,//'/api/v1/admin/selectEmployee',
                params: paramter,
                dataType:"json",
                // headers: {
                //     'Content-Type': 'application/json',
                // },
            }).success(
                function (res) {
                    success(res)
                },
            ).error(
                function (error) {
                    error(error)
                }
            )
        }
        //发送POST请求
        $scope.POST = function (url, paramter, success, error) {
            console.log(url, paramter)
            $http({
                method: 'POST',
                url:  url,
                data: paramter,
                header: {
                    'content-type': 'application/json',
                },
            }).success(
                function (res) {
                    success(res)
                },
            ).error(
                function (error) {
                    error(error)
                }
            )
        }
        // // 添加档案
        $scope.addEmployee = function (employeeName, age, sex, email, phone, qq, telephone, address, postCode, nationality, birthPlace, birthday, nation, faith, politicalStatus, idcard, soSeNum, edubg, major, bank, accountNumber, hobby, resume, familyRelative, remark, third_org, second_org, first_org,  professional, creatTime, registrant, success, fail) {
            var parameter = {
                "employeeName": employeeName,
                "age": age,
                "sex": sex,
                "email": email,
                "phone": phone,
                "qq": qq,
                "telephone": telephone,
                "address": address,
                "postCode": postCode,
                "nationality": nationality,
                "birthPlace": birthPlace,
                "birthday": birthday,
                "nation": nation,
                "faith": faith,
                "politicalStatus": politicalStatus,
                "idcard": idcard,
                "soSeNum": soSeNum,
                "edubg": edubg,
                "major": major,
                "bank": bank,
                "accountNumber": accountNumber,
                "hobby": hobby,
                "resume": resume,
                "familyRelative": familyRelative,
                "remark": remark,
                "third_org": third_org,
                "second_org": second_org,
                "first_org": first_org,
                "professional": professional,
                "creatTime": creatTime,
                "registrant": registrant
            }
            console.log(parameter, success, fail)
            $scope.POST(url.addEmployee, parameter, success, fail)
        }
        // 查询档案
        $scope.selectEmployee = function (fileNum, success, fail) {
            var parameter = {
                fileNum: fileNum
            }
            console.log( parameter, success, fail)
            $scope.POST(url.selectEmployee,parameter, success, fail)
        }
        //条件查询档案
        $scope.switchSelEmployee = function ( success, fail) {
            var parameter = {
            }
            console.log( parameter, success, fail)
            $scope.GET(url.switchSelEmployee,parameter, success, fail)
        }
        //获取所有机构名
        $scope.selectOrg = function ( success, fail) {
            var parameter = {

            }
            console.log( parameter, success, fail)
            $scope.GET(url.selectOrg, parameter, success, fail)
        }
        //获取所有职称名
        $scope.selectPosition = function ( success, fail) {
            var parameter = {

            }
            console.log( parameter, success, fail)
            $scope.GET(url.selectPosition, parameter, success, fail)
        }
        //删除档案
        $scope.deleteEmployee = function (fileNum, success, fail) {
            var parameter = {
                fileNum: fileNum
            }
            console.log( parameter, success, fail)
            $scope.POST(url.deleteEmployee,parameter, success, fail)
        }
        //复核档案
        $scope.checkEmployee = function (fileNum, success, fail) {
            var parameter = {
                fileNum: fileNum
            }
            console.log( parameter, success, fail)
            $scope.POST(url.checkEmployee,parameter, success, fail)
        }
        //修改档案
        $scope.updateEmployee = function (fileNum, name, age,  success, fail) {
            var parameter = {
                fileNum: fileNum,
                name: name,
                age:age,

            }
            console.log( parameter, success, fail)
            $scope.POST(url.updateEmployee,parameter, success, fail)
        }
        //薪酬登记
        $scope.addSalary = function (name, baseWage, registrant, creatTime, register, total, success, fail) {
            var parameter = {
                name: name,
                baseWage: baseWage,
                registrant:registrant,
                creatTime: creatTime,
                register: register,
                total: total

            }
            console.log( parameter, success, fail)
            $scope.POST(url.addSalary,parameter, success, fail)
        }
        //薪酬复核
        $scope.checkSalary = function (id, success, fail) {
            var parameter = {
                id: id,
            }
            console.log( parameter, success, fail)
            $scope.GET(url.checkSalary, parameter, success, fail)
        }
        //薪酬查看
        $scope.selectSalary = function ( success, fail) {
            var parameter = {
            }
            console.log( parameter, success, fail)
            $scope.GET(url.selectSalary, parameter, success, fail)
        }
        //按照id查看薪酬
        $scope.selectSalaryID = function ( id, success, fail) {
            var parameter = {
                id: id,
            }
            console.log( parameter, success, fail)
            $scope.GET(url.selectSalaryID, parameter, success, fail)
        }
        //薪酬删除
        $scope.deleteSalary = function ( id, success, fail) {
            var parameter = {
                id: id,

            }
            console.log( parameter, success, fail)
            $scope.GET(url.deleteSalary, parameter, success, fail)
        }



    }]);

